<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" href="/bootstrap/bootstrap.css">
    <script src="/bootstrap/jquery.js"></script>
    <script src="/bootstrap/bootstrap.bundle.js"></script>
    <script src="/bootstrap/bootstrap.min.js"></script>
</head>
<body>
<form>
    <div class="mb-3">
        <label for="username" class="form-label">Email address</label>
        <input type="text" class="form-control" id="username" name="username" aria-describedby="emailHelp">
    </div>
    <div class="mb-3">
        <label for="password" class="form-label">Email address</label>
        <input type="text" class="form-control" id="password" name="password" aria-describedby="emailHelp">
    </div>
    <button type="button" class="btn btn-primary" onclick="login()">登录</button>
</form>

<script>
    login = ()=>{
        let name = $("#username").val();
        let password = $("#password").val();
        console.log(name)
        console.log(password)
        $.ajax({
            url: "/api/login/student",
            method: "GET",
            data : {
                name : name,
                password : password
            },

        }).done((rs)=>{
            if(rs.code>=0){
                window.location.href = '/student/list';
            }else{
                alert("用户名或密码错误")
            }
        })
    }

</script>
</body>
</html>